package com.wanwen.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wanwen.entity.Follow;
import com.wanwen.mapper.FollowMapper;
import com.wanwen.utils.Result;
import com.wanwen.utils.ResultData;

@RestController
@RequestMapping("/follow")
public class FollowController {
	@Autowired
	private FollowMapper followMapper;

	/**
	 * /users/update 开启和关闭自动分配
	 * 
	 * @param users
	 * @return rs
	 */
	@RequestMapping("/getByUid")
	public Object getByUid(Integer page, Integer limit, Integer uid) {
		QueryWrapper<Follow> queryWrapper = new QueryWrapper<Follow>();
		queryWrapper.eq("uid", uid);
		// 封装分页对象
		Page<Follow> Page = new Page<Follow>(page, limit);
		Page<Follow> followPage = followMapper.selectPage(Page, queryWrapper);
		return new ResultData(0, "", followPage.getRecords(), followPage.getTotal());
	}

	/**
	 * /student/add 添加跟踪信息
	 * 
	 * @param student
	 * @return rs
	 */
	@RequestMapping("/add")
	public Object add(Follow follow) {
		Result rs = new Result("跟踪失败", "", followMapper.insert(follow) == 1 ? true : false);
		return rs;

	}
}
